// vue.config.js
'use strict'
var webpack = require('webpack')

var proxyMap={
  dev:'http://192.168.2.242:8281/',
  dev3:'http://192.168.2.233:8281/',
  test:'http://192.168.2.112:8281/',
  pro:'http://47.96.25.44:8281/',
  hq:'http://121.40.210.64:8281/',
  fire:'http://www.huozhidao.cn/',
  car:'http://192.168.2.242:10101/',
  gxq:'http://222.92.32.55:8072/',
  local:'http://127.0.0.1/',
}

var proxyTarget=proxyMap.local

module.exports = {
  // 基本路径
  publicPath: process.env.NODE_ENV === 'production' ? '/ilink/' : '/',
  assetsDir: 'static',
  outputDir: 'dist/ilink',
  // 是否在保存的时候使用 `eslint-loader` 进行检查。
  lintOnSave: true, // 是否开启eslint保存检测 ,它的有效值为 true || false || 'error'
  devServer: {
    disableHostCheck: true, // webpack4.0 开启热更新
    hot: true,
    port: 8082, // 端口号
    host: '0.0.0.0',
    https: false, // https:{type:Boolean}
    open: true, // 配置自动启动浏览器
    // contentBase: false, // since we use CopyWebpackPlugin.
    proxy: {
      '/ilink/client': {
        target: proxyTarget,
        secure: false,
        changeOrigin: true
      },
      '/ilink/webSocketServer': {
        target: proxyTarget,
        ws: true,
        secure: false,
        changeOrigin: true,
      },
      '/ilink-fe-config': {
        target: proxyTarget,
        secure: false,
        changeOrigin: true
      },
      '/car': {
        target: proxyMap.car,
        secure: false,
        changeOrigin: true
      },
      '/linapp': {
        target: 'https://pro-ccrecords.kefutoutiao.com',
        secure: false,
        changeOrigin: true
      },
      '/6ce5bfc8-f89f-4df8-4047-ec21a2531f06': {
        target: 'https://pro-ccrecords.kefutoutiao.com',
        secure: false,
        changeOrigin: true
      },
      '/baiduapi': {
        target: 'http://api.map.baidu.com',
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '/baiduapi/': '/'
        }
      },
      '/ilink-file': {
        target: 'http://file.yx-ilink.com',
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '/ilink-file/': '/'
        }
      },
    }
  },
  configureWebpack: {
    devtool: 'source-map',
    plugins: [
      new webpack.ProvidePlugin({
        jQuery: 'jquery',
        $: 'jquery'
      }),
      new webpack.DefinePlugin({
        'process.env.script_version': new Date().getTime().toString(),
      }),
    ],
    externals: {
      BMap: 'BMap',
      BMapLib: 'BMapLib'
    }
  }
}
